package com.pony.iphone.dto;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 获取钉钉配置信息类
 * @author pony
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "dingtalk")
public class DingTalkProperties {
    
    private String webhookToken;
    private String secret;
    // 🔥 新增：要@的手机号列表
    private List<String> atMobiles = new ArrayList<>();
    
    /**
     * 获取有效的手机号列表（过滤空值）
     */
    public List<String> getValidAtMobiles() {
        return atMobiles.stream()
                .filter(mobile -> mobile != null && !mobile.trim().isEmpty())
                .collect(Collectors.toList());
    }
    
    /**
     * 检查是否需要@人
     */
    public boolean hasAtMobiles() {
        return !getValidAtMobiles().isEmpty();
    }
}